package cz.zcu.fav.rat.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cz.zcu.fav.rat.security.beans.Role;


public class User implements Serializable, Indexable
{

	private static final long serialVersionUID = 1L;
	private Integer id;
	private String firstName;
	private String surname;
	private String email;
	private String nickname;
	private String passhash;
	private Role role;
	//private List<Reservation> reservations = new ArrayList<Reservation>();
	private String implementor;
	private Set<Object> favourites = new HashSet<Object>();
	
	public Integer getId()
	{
		return id;
	}

	public void setId(Integer userId)
	{
		this.id = userId;
	}

	public String getFirstName()
	{
		return firstName;
	}

	public void setFirstName(String firstName)
	{
		this.firstName = firstName;
	}

	public String getSurname()
	{
		return surname;
	}

	public void setSurname(String surname)
	{
		this.surname = surname;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public String getNickname()
	{
		return nickname;
	}

	public void setNickname(String nickname)
	{
		this.nickname = nickname;
	}

	public String getPasshash()
	{
		return passhash;
	}

	public void setPasshash(String passhash)
	{
		this.passhash = passhash;
	}

//	public List<Reservation> getReservations()
//	{
//		return reservations;
//	}
//
//	public void setReservations(List<Reservation> reservations)
//	{
//		this.reservations = reservations;
//	}

	public Role getRole()
	{
		return role;
	}

	public void setRole(Role role)
	{
		this.role = role;
	}

	public String getImplementor()
	{
		return implementor;
	}

	public void setImplementor(String implementor)
	{
		this.implementor = implementor;
	}

	public Set<Object> getFavourites()
	{
		return favourites;
	}

	public void setFavourites(Set<Object> favourites)
	{
		this.favourites = favourites;
	}
//	
////	public void addReservation(Reservation reservation)
////	{
////		this.reservations.add(reservation);
////	}
//
	public void addFavourite(Object favourite)
	{
		this.favourites.add(favourite);
	}
	public void removeFavourite(Object favourite)
	{
		this.favourites.remove(favourite);
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((implementor == null) ? 0 : implementor.hashCode());
		result = prime * result
				+ ((nickname == null) ? 0 : nickname.hashCode());
		result = prime * result + ((role == null) ? 0 : role.hashCode());
		result = prime * result + ((surname == null) ? 0 : surname.hashCode());
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (email == null)
		{
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (firstName == null)
		{
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (id == null)
		{
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (implementor == null)
		{
			if (other.implementor != null)
				return false;
		} else if (!implementor.equals(other.implementor))
			return false;
		if (nickname == null)
		{
			if (other.nickname != null)
				return false;
		} else if (!nickname.equals(other.nickname))
			return false;
		if (role != other.role)
			return false;
		if (surname == null)
		{
			if (other.surname != null)
				return false;
		} else if (!surname.equals(other.surname))
			return false;
		return true;
	}


}
